package cn.ito.zjgsu.utils.impl;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

public class SPJSONUtils {
	public static String parseArrayDatePatch(String receipts,String datekey) throws ParseException {
		JSONArray array = JSON.parseArray(receipts);
		for(Object a : array){
			SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
			String key = ((JSONObject)a).getString(datekey);
			if(null != key && !((key.trim()).equals(""))){
				Date date = sdf.parse(key);
				((JSONObject)a).put(datekey, date);
			}else{
				return JSON.toJSONString(new String[]{});
			}
		}
		return array.toJSONString();
	}
}
